using UnityEngine;

public class SelectWeaponPrefab : MonoBehaviour
{
	public int connectWeaponID;

	public UISprite sprIcon;

	public UILabel lbName;

	public UILabel lbLevel;

	public GameObject tickicon;

	private IngameUI ingameUI;

	public void SetItem(Weapon weaponData, IngameUI ingameUI)
	{
		this.ingameUI = ingameUI;
		if (weaponData != null)
		{
			connectWeaponID = weaponData.id;
			lbName.text = weaponData.itemName;
			sprIcon.spriteName = weaponData.sprName;
			sprIcon.MakePixelPerfect();
			if (sprIcon.height > 35)
			{
				float value = 35f / (float)sprIcon.height;
				value = Mathf.Clamp(value, 0f, 0.5f);
				sprIcon.transform.localScale = new Vector3(-1f, 1f, 1f) * value;
			}
			lbLevel.transform.parent.gameObject.SetActive(value: true);
			lbLevel.text = "等级 " + (weaponData.Level + 1);
		}
		else
		{
			connectWeaponID = -1;
			lbName.text = "无武器";
			sprIcon.spriteName = "no_weapon_sprite";
			lbLevel.transform.parent.gameObject.SetActive(value: false);
		}
		base.transform.localScale = Vector3.one;
		ShowUsing();
	}

	public void ShowUsing()
	{
		tickicon.SetActive(connectWeaponID == PersistenData.UsingWeapon);
	}

	public void ClickItem()
	{
		ingameUI.UseWeapon(connectWeaponID);
	}
}
